//
//  WebViewController.swift
//  Community
//
//  Created by JKSD on 2019/8/5.
//  Copyright © 2019 ZKJ. All rights reserved.
//

import UIKit

let webView = UIWebView()

class WebViewController: UIViewController{
    
    override func viewWillAppear(_ animated: Bool) {
        super .viewWillAppear(animated)
//        self.navigationItem.leftBarButtonItem = nil
        self.navigationItem.hidesBackButton = true
        
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
        webView.frame = CGRect.init(x: 0, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGHT - AllTopNavHeight)
        
        self.view.addSubview(webView)
        
        let back = UIButton(type: UIButton.ButtonType.custom)
        back.frame = CGRect(x: 5,y: 20,width: 44,height: 44)
        back.setImage(UIImage.init(named: "black_return"), for: UIControl.State.normal)
        back.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.left
        back.addTarget(self, action: #selector(backAct), for: UIControl.Event.touchUpInside)
        self.navigationItem.leftBarButtonItem =  UIBarButtonItem.init(customView: back)
    }
    @objc func backAct() {
        self.navigationController?.popViewController(animated: true)
    }
   open func prorororo(url:String) {
        webView.loadRequest(URLRequest.init(url: NSURL.init(string: url)! as URL))
        
    }
   open func requst(path:String) {
        let filePath = Bundle.main.path(forResource: path, ofType: "html")
        guard let path = filePath else {
            return
        }
        
        guard let url = URL(string: path) else {
            return
        }
        
        let request = URLRequest(url: url)
        
        webView.loadRequest(request)
    }

}
